<?php

	/*
	
		Helper script 
		
		This script creates empty rows for all objects of a given class that do not have any data associated.
	
	*/

	define('CLASS_NAME','SEITE');

	$server_path = '/srv/www/htdocs/';
	
	require( $server_path."ccds/base/ccdsConfigParser.inc.php" );
	require( $server_path."ccds/base/ccdsConfig.inc.php" );
	require( $server_path."ccds/base/ccdSQL.inc.php" );
	require( $server_path."ccds/base/ccdsXajax.inc.php" );
	
	require( $server_path."ccds/base/ccdsSmarty.inc.php" );
	require( $server_path."ccds/base/ccdsSmartyFunctions.inc.php" );
	
	require( $server_path."ccds/base/ccdsTools.inc.php" );
	
	require( $server_path."ccds/base/ccdsImageCache.inc.php" );
	
	require( $server_path."ccds/base/ccdsObjectConfig.inc.php" );
	require( $server_path."ccds/base/ccdsObjectHandler.inc.php" );
	
	require( $server_path."ccds/base/ccdsObject.inc.php" );
	require( $server_path."ccds/base/ccdsForms.inc.php" );
	
	$ccdSQL = ccdSQL::getInstance();

	$languages = array();
	$query = "SELECT * FROM languages";
	$res = $ccdSQL->query($query);
	while ($row = $ccdSQL->fetch_assoc($res)) $languages[]=$row['lang_id']);


	$query = "SELECT * FROM obj_index STRAIGHT_JOIN classes ON (obj_key_class_id = class_id) LEFT OUTER JOIN obj_versions ON (obj_vers_key_obj_id=obj_id)
						WHERE obj_vers_id IS NULL AND 
						class_name='".CLASS_NAME."'";
						
						
	$res = $ccdSQL->query($query);
	
	while ($obj = $ccdSQL->fetch_assoc($res)) {
	
		$foo = new ccdsObject($row['obj_id']);
		foreach ($languages as $lang)
			$foo->save(array(),$lang);
	
	}